package com.nandi.deviceinstall.presenter

import com.nandi.deviceinstall.base.BasePresenter
import com.nandi.deviceinstall.bean.BaseObjectBean
import com.nandi.deviceinstall.bean.LoginBean
import com.nandi.deviceinstall.contract.LoginContract
import com.nandi.deviceinstall.model.LoginModel
import com.nandi.deviceinstall.net.BaseSubscriber
import com.nandi.deviceinstall.net.RxScheduler
import com.uber.autodispose.FlowableSubscribeProxy


class MainPresenter : BasePresenter<LoginContract.View>(), LoginContract.Presenter {

    private val model: LoginContract.Model

    init {
        model = LoginModel()
    }

    override fun login(username: String, password: String) {
        //View是否绑定 如果没有绑定，就不执行网络请求
        if (!isViewAttached) {
            return
        }
        mView!!.showLoading()
        /*model.login(username, password)
                .compose(RxScheduler.Flo_io_main())
                .`as`<FlowableSubscribeProxy<BaseObjectBean<LoginBean>>>(mView!!.bindAutoDispose())
                .subscribe(object : BaseSubscriber<BaseObjectBean<LoginBean>>(mView!!) {
                    override fun onNext(t: BaseObjectBean<LoginBean>) {
                        mView!!.onSuccess(t)
                    }
                })*/
    }
}

